import pymysql

if __name__ == '__main__':
    #连接对象
    conn = pymysql.connections.Connection(host="127.0.0.1",port=3306,user="root",passwd="root",db="shop")
    #定义sql
    sql = "select * from user where username = %s and password = %s;"
    #获取游标对象
    cusor = conn.cursor()
    
    #执行sql
    result = cusor.execute(sql,["wangwu","123"])

    rows = cusor.fetchall()
    print(rows)

    cusor.close()
    conn.close()
